<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>e1va 编程卷轴</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta property="og:type" content="website">
<meta property="og:title" content="e1va 编程卷轴">
<meta property="og:url" content="https://e1va.gitee.io/e-blog/index.html">
<meta property="og:site_name" content="e1va 编程卷轴">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="e1va">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/atom.xml" title="e1va 编程卷轴" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    
  
  
<link rel="stylesheet" href="/e-blog/css/style.css">

  

<meta name="generator" content="Hexo 5.4.2"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    
    <div id="header-inner" class="inner">
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="搜索"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="https://e1va.gitee.io/e-blog"></form>
      </div>
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/e-blog/">首页</a>
        
          <a class="main-nav-link" href="/e-blog/archives">归档</a>
        
          <a class="main-nav-link" href="/e-blog/about">关于</a>
        
      </nav>
      
    </div>
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/e-blog/" id="logo">e1va 编程卷轴</a>
      </h1>
      
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main">
  
    <article id="post-golang/Delve使用总结" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/e-blog/2022/11/11/golang/Delve%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93/" class="article-date">
  <time datetime="2022-11-10T23:08:07.000Z" itemprop="datePublished">2022-11-10</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/e-blog/2022/11/11/golang/Delve%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93/">Delve使用总结</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <!-- Table of Contents -->
        
        <h2 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h2><ul>
<li>go install github.com/go-delve/delve@latest</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">go install github.com/go-delve/delve@latest</span><br></pre></td></tr></table></figure>


<h2 id="介绍"><a href="#介绍" class="headerlink" title="介绍"></a>介绍</h2><figure class="highlight plaintext"><figcaption><span>Text</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">官方解释：</span><br><span class="line">Delve is a source level debugger for Go programs.</span><br><span class="line">Delve enables you to interact with your program by controlling the execution of the process,</span><br><span class="line">evaluating variables, and providing information of thread / goroutine state, CPU register state and more.</span><br><span class="line">The goal of this tool is to provide a simple yet powerful interface for debugging Go programs.</span><br><span class="line">Pass flags to the program you are debugging using `--`, for example:</span><br><span class="line">`dlv exec ./hello -- server --config conf/config.toml`</span><br><span class="line"></span><br><span class="line">翻译:</span><br><span class="line">Delve 是Go程序的源代码级调试器。</span><br><span class="line">Delve 使您能够通过控制进程的执行与您的程序进行交互，</span><br><span class="line">评估变量，并提供线程/goroutine 状态、CPU 寄存器状态等信息。</span><br><span class="line">这个工具的目标是为调试 Go 程序提供一个简单而强大的接口。</span><br><span class="line">使用 `--` 将标志传递给您正在调试的程序，例如：</span><br><span class="line">`dlv exec ./hello -- server --config conf/config.toml`</span><br><span class="line"></span><br><span class="line">自己的理解:</span><br><span class="line">就是装逼用的, 说白了就是使用命令行来调试go代码。于vscode和goland等debug调试的使用无差别。</span><br><span class="line"></span><br></pre></td></tr></table></figure>


<h2 id="dlv-常用命令"><a href="#dlv-常用命令" class="headerlink" title="dlv 常用命令"></a>dlv 常用命令</h2><h3 id="启动debug命令"><a href="#启动debug命令" class="headerlink" title="启动debug命令"></a>启动debug命令</h3><ul>
<li><strong>attach</strong>: 调试远程进程。</li>
<li><strong>debug</strong>:  调试源码。</li>
<li><strong>exec</strong>:  调试二进制可执行文件。</li>
<li>test: 调试test单测文件</li>
</ul>
<h3 id="debug模式命令-只在debug模式下生效"><a href="#debug模式命令-只在debug模式下生效" class="headerlink" title="debug模式命令(只在debug模式下生效)"></a>debug模式命令(只在debug模式下生效)</h3><h4 id="流程命令"><a href="#流程命令" class="headerlink" title="流程命令"></a>流程命令</h4><ul>
<li>call:  恢复过程中, 注入一个函数调用。</li>
<li><strong>continue/c</strong>:  运行直到下一个断点或者程序结束</li>
</ul>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">相当于</span><br><span class="line">vscode: f5</span><br><span class="line">goland: f9</span><br></pre></td></tr></table></figure>
<ul>
<li>next/n: 运行到下一行代码,即(单步执行)</li>
</ul>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">相当于</span><br><span class="line">vscode: f10</span><br><span class="line">goland: f8</span><br></pre></td></tr></table></figure>
<ul>
<li>step/s: 单步进入 </li>
</ul>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">相当于</span><br><span class="line">vscode: f11</span><br><span class="line">goland: f7</span><br></pre></td></tr></table></figure>
<ul>
<li>stepout/so: 单步跳出</li>
</ul>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">相当于</span><br><span class="line">vscode: shift f10</span><br><span class="line">goland: shift f8</span><br></pre></td></tr></table></figure>
<ul>
<li>restart/r : 重启进程</li>
</ul>
<h4 id="断点命令"><a href="#断点命令" class="headerlink" title="断点命令"></a>断点命令</h4><ul>
<li>break/b: 设置一个断点</li>
<li>breakpoints/bp:  查看所有断点</li>
<li>clear:  删除一个断点</li>
<li>clearall: 清除所有断点</li>
<li>condition/cond: 设置中断条件</li>
</ul>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cond + 表达式</span><br><span class="line">eg: cond a == <span class="number">0</span></span><br><span class="line">设置断点a等于<span class="number">0</span>的时候中断程序。</span><br></pre></td></tr></table></figure>
<ul>
<li>on:  到运行到某个断点时执行相应的命令, 断点通常是名称或者编号</li>
</ul>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">on <span class="number">3</span> cond a == <span class="number">0</span> (==之间的空格是必须的)</span><br><span class="line">on <span class="number">3</span> p a</span><br><span class="line">以上代表,在标号为<span class="number">3</span>的断点, 当变量a等于<span class="number">0</span>时,打印变量a</span><br></pre></td></tr></table></figure>
<ul>
<li>toggle: 设置断点开关</li>
</ul>
<h4 id="显示变量和内存"><a href="#显示变量和内存" class="headerlink" title="显示变量和内存"></a>显示变量和内存</h4><ul>
<li>args:  打印函数变量</li>
<li>display:  设置运行到某个断点时,打印日志。</li>
</ul>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">display ==&gt; 待实践</span><br></pre></td></tr></table></figure>
<ul>
<li>locals: 打印本地变量(局部变量)</li>
<li><strong>print/p</strong>: 打印一个表达式</li>
</ul>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">p a 打印变量a的值</span><br></pre></td></tr></table></figure>
<ul>
<li>regs: 打印寄存器</li>
<li><strong>set</strong>: 设置变量值</li>
</ul>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">set a=<span class="number">11</span> </span><br><span class="line">设置a的值为<span class="number">11</span></span><br></pre></td></tr></table></figure>
<ul>
<li>vars: 打印包内所有变量</li>
<li><strong>whatis</strong>： 打印变量类型</li>
</ul>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">eg</span><br><span class="line"><span class="keyword">var</span> a <span class="type">int</span> </span><br><span class="line">whatis a 就会打印a的类型</span><br></pre></td></tr></table></figure>


<h4 id="其他命令"><a href="#其他命令" class="headerlink" title="其他命令"></a>其他命令</h4><ul>
<li>exit 退出debug模式</li>
<li>list/ls/l : 查看源代码</li>
<li>funcs:  查看函数</li>
</ul>
<h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><p>使用起来不是很方便, 只有特殊的场景下才会被使用到。纯粹是爱好学习才去探索…, 吃饱了撑的。</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="https://e1va.gitee.io/e-blog/2022/11/11/golang/Delve%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93/" data-id="clab7orah0001nmx48yscf0mm" class="article-share-link">分享</a>
      
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/e-blog/tags/golang/" rel="tag">golang</a></li></ul>

    </footer>
  </div>
  
</article>
 


  
    <article id="post-my frist blog post" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/e-blog/2022/10/10/my%20frist%20blog%20post/" class="article-date">
  <time datetime="2022-10-10T15:00:00.000Z" itemprop="datePublished">2022-10-10</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/e-blog/2022/10/10/my%20frist%20blog%20post/">My Frist Blog Post!</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <!-- Table of Contents -->
        
        <h2 id="缘由"><a href="#缘由" class="headerlink" title="缘由"></a>缘由</h2><figure class="highlight text"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">  在此之前,我记录平时日常工作主要是使用云笔记、像有道云笔记、为知笔记等,也会使用一些较为常见的博客网站</span><br><span class="line">例如: 掘金、博客园、infoq等来分享一下自己踩过的坑或学习心得。但是使用起来总感觉不能趁手。</span><br><span class="line">原因:</span><br><span class="line">    1. 开源博客网页样式单一,无法指定自己的风格。</span><br><span class="line">    2. 存在图床失效的问题(gitee.com)事件历历在目,导致文章阅读性降低。</span><br><span class="line">    3. 每次修改的内容要上架需要重新审核。</span><br><span class="line">    4. 博客园这种,广告真是多。不是一个纯粹的博客软件。</span><br><span class="line">    5. infoq和掘金平台一般都会被当做技术博客偏技术类, 大平台的方向与我实际的需求不符合。</span><br></pre></td></tr></table></figure>

<h2 id="新方案"><a href="#新方案" class="headerlink" title="新方案"></a>新方案</h2><figure class="highlight text"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">  针对以上存在问题,我也寻求过很多开源的项目,直到发现hexo的项目, 高度定制化的主题以及对markdown的优雅</span><br><span class="line">支持,图片在本地也有备份这能保证了博客内容完整性, 以上种种极大程度上的满足了我对一个个人博客的诸多需求。</span><br><span class="line">利用hexo+gitee pages服务可以有效将你的博客共享到互联网,主题上选用了cafe theme一个十分复古的主题。乍</span><br><span class="line">一看有点类似阮一峰大佬的网络日志。传送门:https://ruanyifeng.com/blog/  盲猜他也是使用了该主题吧,向</span><br><span class="line">大佬看齐...</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="思考"><a href="#思考" class="headerlink" title="思考"></a>思考</h2><figure class="highlight text"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">  关于我的博客会分享或者记录什么样的内容呢？ 我目前没有一个很好的想法。</span><br><span class="line">首先肯定不希望将博客变成一个垃圾桶,什么内容都不假思索的往里塞,也不希望单单只记录工作学习上的心得。</span><br><span class="line">也想过可能烂尾不了了之。毕竟在我看来&quot;摆烂&quot;、&quot;躺平&quot;的生活是很舒服。 我甚至想写一篇关于&quot;摆烂、躺平&quot;</span><br><span class="line">文章来阐述我在躺平到底有多爽。,毕竟人性是懒惰,程序员亦是如此,曾经看过金南俊的一本关于懒惰的书《懒惰</span><br><span class="line">,在圣洁生活中的敌人》,后面有机会再写成博文跟大家分享吧(会有机会的&quot;吧&quot;)。貌似有点扯远了, 回过头来现</span><br><span class="line">阶段博文更多的会以工作学习上的思考为主,然后就是读书分享,最次就是会发一些牢骚吧...</span><br><span class="line"></span><br><span class="line">最后也不想给自己太多的压力或者像是任务似的规定,多长时间产出一篇文章。 </span><br><span class="line">                                                                      - 随心所欲,不逾矩。</span><br></pre></td></tr></table></figure>
      
    </div>
    <footer class="article-footer">
      <a data-url="https://e1va.gitee.io/e-blog/2022/10/10/my%20frist%20blog%20post/" data-id="clab7orae0000nmx4awtuh73h" class="article-share-link">分享</a>
      
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/e-blog/tags/%E6%97%A5%E5%B8%B8/" rel="tag">日常</a></li></ul>

    </footer>
  </div>
  
</article>
 


  

</section>
           
    <aside id="sidebar">
  
    
  <div class="widget-wrap">
     
        <h3 class="follow-title ">Follow me</h3>
     
    <div class="widget follow">
      
              <a class="github" aria-hidden="true" href="https://github.com/e1va" target="_blank" title="Github"></a>
      
      
            <a class="weibo" aria-hidden="true"  href="http://weibo.com/laohoubin" target="_blank" title="微博"></a>
      
      
              <a class="zhihu" aria-hidden="true"  href="http://www.zhihu.com/people/giscafer" target="_blank" title="知乎"></a>
      
      
            <a class="email" aria-hidden="true"  href="mailto:e1va@gmail.com" target="_blank" title="邮箱"></a>
      
    </div>
  </div>


  
    
  
    

  
    
  <div class="widget-wrap">
    <h3 class="widget-title tagcloud">标签云</h3>
    <div class="widget tagcloud">
      <a href="/e-blog/tags/golang/" style="font-size: 14px;">golang</a> <a href="/e-blog/tags/%E6%97%A5%E5%B8%B8/" style="font-size: 14px;">日常</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title recent-posts">最新文章</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/e-blog/2022/11/11/golang/Delve%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93/">Delve使用总结</a>
          </li>
        
          <li>
            <a href="/e-blog/2022/10/10/my%20frist%20blog%20post/">My Frist Blog Post!</a>
          </li>
        
      </ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title archive">归档</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/e-blog/archives/2022/11/">十一月 2022</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/e-blog/archives/2022/10/">十月 2022</a><span class="archive-list-count">1</span></li></ul>
    </div>
  </div>


  
    
  
    <!--微信公众号二维码-->

  <div class="widget-wrap">
    <h3 class="follow-title ">微信公众号</h3>
    <div class="widget wechat-widget">
        <img src="http://blog.giscafer.com/static/images/qrcode_giscafer.jpg" alt="扫码关注" width="250"/>
    </div>
  </div>


  
</aside>

      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-left">
      &copy; 2014 - 2022 e1va&nbsp;|&nbsp;
      主题 <a href="https://github.com/giscafer/hexo-theme-cafe/" target="_blank">Cafe</a>
    </div>
     <div id="footer-right">
      联系方式&nbsp;|&nbsp;youemail@outlook.com
    </div>
  </div>
</footer>
 
<script src="/e-blog/jquery/jquery.min.js"></script>

    </div>
    <nav id="mobile-nav">
  
    <a href="/e-blog/" class="mobile-nav-link">首页</a>
  
    <a href="/e-blog/archives" class="mobile-nav-link">归档</a>
  
    <a href="/e-blog/about" class="mobile-nav-link">关于</a>
  
</nav>
    <img class="back-to-top-btn" src="/images/fly-to-top.png"/>
<script>
// Elevator script included on the page, already.
window.onload = function() {
  var elevator = new Elevator({
    selector:'.back-to-top-btn',
    element: document.querySelector('.back-to-top-btn'),
    duration: 1000 // milliseconds
  });
}
</script>
      

  
    <script>
      var cloudTieConfig = {
        url: document.location.href, 
        sourceId: "",
        productKey: "e2fb4051c49842688ce669e634bc983f",
        target: "cloud-tie-wrapper"
      };
    </script>
    <script src="https://img1.ws.126.net/f2e/tie/yun/sdk/loader.js"></script>
    

  







<!-- author:forvoid begin -->
<!-- author:forvoid begin -->

<!-- author:forvoid end -->

<!-- author:forvoid end -->


  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      })
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      })
    </script>
    <script type="text/javascript" src="https://cdn.rawgit.com/mathjax/MathJax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
  


 
<script src="/e-blog/js/is.js"></script>



  
<link rel="stylesheet" href="/e-blog/fancybox/jquery.fancybox.css">

  
<script src="/e-blog/fancybox/jquery.fancybox.pack.js"></script>




<script src="/e-blog/js/script.js"></script>


<script src="/e-blog/js/elevator.js"></script>

  </div>
</body>
</html>